﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using VSDBM.Code.dao;

public partial class Visual_CRUD_User_ListUser : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }


    protected void selecionarUsuario(object sender, EventArgs e)
    {
        Session["idselectuser"] = GridUsers.SelectedRow.Cells[0].Text;
        Response.Redirect("EditUser.aspx");
    }

    protected void btsearchonclick(object sender, ImageClickEventArgs e)
    {
        String term = txtterm.Text;
        DataSet usuarios = UserDAO.select(true, " WHERE UPPER(name) like '%" + term.ToUpper() + "%' or UPPER(email) like '%" + term.ToUpper() + "%' ", "");

        if (usuarios.Tables[0].Rows.Count > 0)
        {
            GridUsers.DataSource = usuarios.Tables[0];
            GridUsers.DataSourceID = null;
            GridUsers.DataBind();
        }
        else
        {
            Response.Redirect("../../../Visual/Errors/error.aspx?id=42");
        }

    }
}